package com.zoo.diannaopeijian.mapper;

import com.zoo.diannaopeijian.domain.Entryitem;
import com.zoo.diannaopeijian.domain.EntryitemExample;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface EntryitemMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table entryitem
     *
     * @mbggenerated
     */
    @SelectProvider(type = EntryitemSqlProvider.class, method = "countByExample")
    int countByExample(EntryitemExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table entryitem
     *
     * @mbggenerated
     */
    @DeleteProvider(type = EntryitemSqlProvider.class, method = "deleteByExample")
    int deleteByExample(EntryitemExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table entryitem
     *
     * @mbggenerated
     */
    @Delete({
            "delete from entryitem",
            "where EntryItemId = #{entryitemid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer entryitemid);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table entryitem
     *
     * @mbggenerated
     */
    @Insert({
            "insert into entryitem (EntryItemId, EntryRecordId, ",
            "WareId, SupplyChannelId, ",
            "WarehouseId, EntryItemNum, ",
            "EntryItemPrice)",
            "values (#{entryitemid,jdbcType=INTEGER}, #{entryrecordid,jdbcType=INTEGER}, ",
            "#{wareid,jdbcType=INTEGER}, #{supplychannelid,jdbcType=INTEGER}, ",
            "#{warehouseid,jdbcType=INTEGER}, #{entryitemnum,jdbcType=INTEGER}, ",
            "#{entryitemprice,jdbcType=REAL})"
    })
    int insert(Entryitem record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table entryitem
     *
     * @mbggenerated
     */
    @InsertProvider(type = EntryitemSqlProvider.class, method = "insertSelective")
    int insertSelective(Entryitem record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table entryitem
     *
     * @mbggenerated
     */
    @SelectProvider(type = EntryitemSqlProvider.class, method = "selectByExample")
    @Results({
            @Result(column = "EntryItemId", property = "entryitemid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "EntryRecordId", property = "entryrecordid", jdbcType = JdbcType.INTEGER),
            @Result(column = "WareId", property = "wareid", jdbcType = JdbcType.INTEGER),
            @Result(column = "SupplyChannelId", property = "supplychannelid", jdbcType = JdbcType.INTEGER),
            @Result(column = "WarehouseId", property = "warehouseid", jdbcType = JdbcType.INTEGER),
            @Result(column = "EntryItemNum", property = "entryitemnum", jdbcType = JdbcType.INTEGER),
            @Result(column = "EntryItemPrice", property = "entryitemprice", jdbcType = JdbcType.REAL)
    })
    List<Entryitem> selectByExample(EntryitemExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table entryitem
     *
     * @mbggenerated
     */
    @Select({
            "select",
            "EntryItemId, EntryRecordId, WareId, SupplyChannelId, WarehouseId, EntryItemNum, ",
            "EntryItemPrice",
            "from entryitem",
            "where EntryItemId = #{entryitemid,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column = "EntryItemId", property = "entryitemid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "EntryRecordId", property = "entryrecordid", jdbcType = JdbcType.INTEGER),
            @Result(column = "WareId", property = "wareid", jdbcType = JdbcType.INTEGER),
            @Result(column = "SupplyChannelId", property = "supplychannelid", jdbcType = JdbcType.INTEGER),
            @Result(column = "WarehouseId", property = "warehouseid", jdbcType = JdbcType.INTEGER),
            @Result(column = "EntryItemNum", property = "entryitemnum", jdbcType = JdbcType.INTEGER),
            @Result(column = "EntryItemPrice", property = "entryitemprice", jdbcType = JdbcType.REAL)
    })
    Entryitem selectByPrimaryKey(Integer entryitemid);

    @Select({
            "select ware.WareName, ware.WareId, house.WarehouseName, house.WarehouseId, sup.SupplyChannelName, sup.SupplyChannelId, EntryItemId, EntryItemNum, EntryItemPrice ",
            "from entryitem as item ",
            "left JOIN warehouse as house ",
            "on house.WarehouseId = item.WarehouseId ",
            "left JOIN ware  ",
            "on ware.WareId = item.WareId ",
            "LEFT JOIN supply_channel as sup ",
            "on sup.SupplyChannelId = item.SupplyChannelId  ",
            "where EntryRecordId = #{entryrecordid,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column = "WareName", property = "warename", jdbcType = JdbcType.VARCHAR),
            @Result(column = "WareId", property = "wareid", jdbcType = JdbcType.INTEGER),
            @Result(column = "WarehouseName", property = "warehousename", jdbcType = JdbcType.VARCHAR),
            @Result(column = "WarehouseId", property = "warehouseid", jdbcType = JdbcType.INTEGER),
            @Result(column = "SupplyChannelName", property = "supplychannelname", jdbcType = JdbcType.VARCHAR),
            @Result(column = "SupplyChannelId", property = "supplychannelid", jdbcType = JdbcType.INTEGER),
            @Result(column = "EntryItemId", property = "entryitemid", jdbcType = JdbcType.INTEGER),
            @Result(column = "EntryItemNum", property = "entryitemnum", jdbcType = JdbcType.INTEGER),
            @Result(column = "EntryItemPrice", property = "entryitemprice", jdbcType = JdbcType.REAL)
    })
    List<Map> getEntryItemsByRecordId(Integer entryrecordid);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table entryitem
     *
     * @mbggenerated
     */
    @UpdateProvider(type = EntryitemSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Entryitem record, @Param("example") EntryitemExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table entryitem
     *
     * @mbggenerated
     */
    @UpdateProvider(type = EntryitemSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") Entryitem record, @Param("example") EntryitemExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table entryitem
     *
     * @mbggenerated
     */
    @UpdateProvider(type = EntryitemSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Entryitem record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table entryitem
     *
     * @mbggenerated
     */
    @Update({
            "update entryitem",
            "set EntryRecordId = #{entryrecordid,jdbcType=INTEGER},",
            "WareId = #{wareid,jdbcType=INTEGER},",
            "SupplyChannelId = #{supplychannelid,jdbcType=INTEGER},",
            "WarehouseId = #{warehouseid,jdbcType=INTEGER},",
            "EntryItemNum = #{entryitemnum,jdbcType=INTEGER},",
            "EntryItemPrice = #{entryitemprice,jdbcType=REAL}",
            "where EntryItemId = #{entryitemid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Entryitem record);
}